<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<html>
	<head>
		<base target="_self" />
		<meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
		<title>修改供货商信息</title>
		<link rel="stylesheet" type="text/css" href="<c:url value="/static/jquery-easyui/themes/default/easyui.css"/>">
		<link rel="stylesheet" type="text/css"
			href="<c:url value="/static/jquery-easyui/themes/icon.css"/>">
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery-1.6.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/jquery.easyui.min.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.panel.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.datagrid.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/plugins/jquery.messager.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/js/json2.js"/>"></script>
		<script type="text/javascript"
			src="<c:url value="/static/jquery-easyui/ext-for-framework.js.jsp"/>"></script>
		<script type="text/javascript" src="<c:url value="/static/jquery-easyui/locale/easyui-lang-zh_CN.js"/>"></script>		

 
    <script type="text/javascript">
    	
 		//添加信息按钮响应函数
		function deal(){
 			$('#AddFoodForm').form('submit',
			{
				url:'<c:url value='/supplier/updateSupplier.do'/>', //查询提交路径
				onSubmit:function()//提交按钮相应函数
				{
					var password = $('#password').val();
	                var password2 = $('#password2').val();
	                if (password == null) {
	                    $.messager.alert("错误", "密码不能为空!", 'error');
	                    return false;
	                } else if (password != password2) {
	                    $.messager.alert("错误", "密码两次输入不同!", 'error');
	                    return false;
	                }
	                return $('#AddFoodForm').form('validate');
				},
				success:function(data){
					data = eval('(' + data + ')');
	       			if(data.success){
	       				$.messager.alert('系统提示', '添加成功', 'info', function(){
				            window.close();
				        });
       				}else{
       					var message = "";
       					if(data.msg == "msg0004"){
       						message = "系统已存在该供货商公司名！";
       					}
	       				$.messager.alert("提示", message, 'warning');
       				}
				},
				error:function(){
					$.messager.alert("错误", "系统错误，请联系管理员！", 'error');
					return;
				}
			});
 			
		}

		$(function() {

	        // 下拉框选择控件，下拉框的内容是动态查询数据库信息  
	        $('#SupType').combobox({
	            url : '<c:url value='/mater/pulldownMaterType.do'/>',
	            editable : false, //不可编辑状态  
	            cache : false,
	            panelHeight : '150',
	            valueField : 'materType',
	            textField : 'materTypename',
	            required : true

	        });
	        // 下拉框选择控件，下拉框的内容是动态查询数据库信息  
	        $('#supId').combobox({
	            url : "<c:url value='/store/pulldownSupId.do?space=0'/>",
	            editable : false, //不可编辑状态  
	            cache : false,
	            panelHeight : '150',
	            valueField : 'supId',
	            textField : 'supName',
	            required : true
	        });
	        // 下拉框选择控件，下拉框的内容是动态查询数据库信息  
	        $('#isActive').combobox({
	            data : [ {
	                "isActive" : "0",
	                "isActiveName" : "有效"
	            }, {
	                "isActive" : "1",
	                "isActiveName" : "失效"
	            } ],
	            editable : false, //不可编辑状态  
	            cache : false,
	            panelHeight : '50',
	            valueField : 'isActive',
	            textField : 'isActiveName',
	            required : true,
	            value:"${supplierVo.isActive }"
	        });
	        $('#province').combobox({
	        	value:"${supplierVo.province }",
	            url : '<c:url value='/user/pullDownProvince.do'/>',
	            editable : true, //不可编辑状态  
	            cache : false,
	            panelHeight : '150',
	            valueField : 'areaid',
	            textField : 'name',
	            required : true,
	            onChange : function(newValue, oldValue) {
	                $.post('<c:url value='/user/pullDownCity.do'/>', {
	                    parentId : newValue
	                }, function(data) {
	                    $('#city').combobox("clear").combobox('loadData', data);
	                }, 'json');
	            }
	        });
	        $('#city').combobox({
	            valueField : 'areaid',
	            textField : 'name',
	            editable : false,
	            url : '<c:url value='/user/pullDownCity.do'/>',
	            onChange : function(newValue, oldValue) {
	                $.post('<c:url value='/user/pullDownCountry.do'/>', {
	                    parentId : newValue
	                }, function(data) {
	                    $('#country').combobox("clear").combobox('loadData', data);
	                }, 'json');
	            }
	        });
	        $('#country').combobox({
	            url : '<c:url value='/user/pullDownCountry.do'/>',
	            valueField : 'areaid',
	            textField : 'name',
	            editable : false
	        });
	    });
		</script>
    <!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>

  <body>
    <table width="90%" align="center">
	  <tr></tr>
	  <tr>
		<td>
		
		  <div style="height: auto; background: #fafafa; padding: 5px;" class="easyui-panel" title="修改供货商信息" iconCls="icon-save" 
		  collapsible="true" minimizable="false" maximizable="false" closable="false">
			
			<form id="AddFoodForm" name="AddFoodForm" method="post">
			   <table cellpadding="5">
                            <tr>
                                <td>登录用户名:</td>
                                <td><input class="easyui-textbox" type="text" name="userName" required="true" validType="length[1,30]" value="${supplierVo.userName }" readOnly="true"/></td>
                                <td>供货商公司名称:</td>
                                <td><input class="easyui-textbox" type="text" name="realName" required="true" validType="length[1,100]"  value="${supplierVo.realName }" /></td>
                            </tr>
                            <tr>
                                <td>密码:</td>
                                <td><input class="easyui-textbox" type="password" id="password" required="true" validType="length[1,100]" name="password" /></td>
                                <td>确认密码:</td>
                                <td><input class="easyui-textbox" type="password" id="password2" required="true" validType="length[1,100]" name="password2" /></td>
                            </tr>
                            <tr>
                                <td>机构编码:</td>
                                <td><input class="easyui-textbox" type="text" name="organId" value="${supplierVo.organId }"/></td>
                                <td>邮箱:</td>
                                <td><input class="easyui-textbox" type="email" name="email" validType="email" validType="length[1,100]"  required="true" value="${supplierVo.email }"/></td>
                            </tr>
                            <tr>
                                <td>电话:</td>
                                <td><input class="easyui-numberbox" type="userPhone" name="userPhone" required="true" value="${supplierVo.userPhone }" /></td>
                            </tr>
                            <tr>
                                <td>手机:</td>
                                <td><input class="easyui-numberbox"   name="mobile" id="mobile" value="${supplierVo.mobile }" required="true"></td>
                            </tr>
                            <tr>
                                <td>是否有效:</td>
                                <td><select class="easyui-combobox" name="isActive">
                                        <option value="0">有效</option>
                                        <option value="1">失效</option>
                                </select></td>
                            </tr>

                            <tr>
                                <td>省:</td>
                                <td><input class="easyui-combobox" name="province" id="province" required="true" /></td>
                            </tr>

                            <tr>
                                <td>市:</td>
                                <td><input class="easyui-combobox" name="city" id="city" required="true" value="${supplierVo.city }"/></td>
                            </tr>

                            <tr>
                                <td>区:</td>
                                <td><input class="easyui-combobox" name="country" id="country" required="true" value="${supplierVo.country }"/></td>
                            </tr>
                            
                            <tr>
                                <td>街:</td>
                                <td><input class="easyui-textbox" type="street" name="street" validType="length[1,50]"  required="true" value="${supplierVo.street }"/></td>
                            </tr>
                            <input type="hidden" name="userId" required="true" value="${supplierVo.userId }"/>
                            <input type="hidden" name="supplierId" required="true" value="${supplierVo.supplierId }"/>
                            <input type="hidden" name="insertTime" required="true" value="${supplierVo.insertTime }"/>
                        </table>
                        <br> <br>
                        -----------------------页面角色选择----------------------------<br>
                        <br>
                        <c:forEach var="role" items="${rolelist}" varStatus="st">
                         <c:choose>
                             <c:when test="${role.checked }">
                              <input class="easyui-validatebox" type="checkBox" name="roles" checked
                              value="${role.roleId }">${role.roleName }</input>
                            </c:when>
                             <c:otherwise>
                                  <input class="easyui-validatebox" type="checkBox" name="roles"
                                 value="${role.roleId }">${role.roleName }</input>
                             </c:otherwise>
                         </c:choose>
                         
                         <c:if test="${st.count % 5 == 0}">
                              <br><br>
                           </c:if>
                    </c:forEach>  
   			   <a class="easyui-linkbutton" onclick="deal()">修改</a>
   			</form>
		  
		  </div>
		</td>
	  </tr>
	</table>
  </body>
</html>